<?php
/**
 * @package mikrokosmos
 * mk script file created on 5-lug-2005
 * jaco_at_pixeldump_dot_org
 * clipping mask
 */

include("sample_utils.php");                             // provides some utils and using mk

$swfFN = "test_clipdepth01.swf";                         // will output with this file name

$ds1 = new MKShapeContainer();                          // let's begin to draw
$ds1->add_fillStyle_solid("#FF9966");                    // create new color to fill
$ds1->add_rect(0, 0, 148, 74);                           // draw a rectangle

$svgFN = "o.svg";                                        // we use an svg file
$ssr = new MKSimpleSvgReader($svgFN);                  // open it and read data,
                                                         // now we are dealing to an mk_shape_container
                                                         // object instance
$ssr->set_shapeID(2);                                    // assign item id
$ssr->set_mask(4);                                       // use is as mask

$ds2 = new MKShapeContainer("", 3);                     // another shape

for($i = 0; $i < 80; $i++){                              // ...
	$ds2->add_fillStyle_solid(get_random_color());       // draw 80 random ...
	$r = rand(5, 30);                                    // circles
	$x = rand(-100, 100);                                // ...
	$y = rand(-100, 100);                                // ...
	$ds2->add_circle($r, $x, $y);                        // ...
}
$ds2->move(100, 100);                                    // move to final position

$swf = new MKSwf($swfFN);                                // create new swf
$swf->set_swfDir(SERVER_MKTMP);                          // set working directory
$swf->set_stageWidth(148);                               // assign canvas width
$swf->set_stageHeight(148);                              // ... and height

$t1 = $ds1->update_tagData();                            // get binary data
$t2 = $ds1->update_place_tagData();                      // placing settings data
$t3 = $ssr->sc->update_tagData();                        // ...
$t4 = $ssr->sc->update_place_tagData();                  // ...
$t5 = $ds2->update_tagData();                            // ...
$t6 = $ds2->update_place_tagData();                      // ...

$swf->add_tagData($t1);                                  // populate swf
$swf->add_tagData($t2);                                  // ...
$swf->add_tagData($t3);                                  // ...
$swf->add_tagData($t4);                                  // ...
$swf->add_tagData($t5);                                  // ...
$swf->add_tagData($t6);                                  // ...
$swf->swf_output();                                      // save to disk

$swfHeader = $swf->fetch_assoc();                        // prepare to publish

$str = render_swf_box($swfHeader, $imgDir, false);
$str .= "<br/><strong>" .$swfFN ." created in :<br />" .SERVER_MKTMP ."</strong>";
echo show_content($str, basename(__FILE__));
?>
